package org.spring.springboot.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.spring.springboot.result.R;
import org.spring.springboot.result.Result;
import org.spring.springboot.server.VisitorSubscribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@Api(tags = "预约管理")
@RequestMapping("/SubscribeManage")
public class SubscribeManageController {

    @Autowired
    private VisitorSubscribeService visitorSubscribeService;


    @ApiOperation(value = "预约待审批")
    @PostMapping("/selectBysubscribe")
    public R selectBysubscribe(String visitorname,Integer pageNum,Integer pageSize){
        Page page = PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> maps = visitorSubscribeService.selectBysubscribe(visitorname);
        Long total = page.getTotal();
        return R.newSuccessResult(maps,total);
    }

    @ApiOperation(value = "预约审批中")
    @PostMapping("/selectBysubscribe1")
    public R selectBysubscribe1(String visitorname,Integer pageNum,Integer pageSize){
        Page page = PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> maps = visitorSubscribeService.selectBysubscribe1(visitorname);
        Long total = page.getTotal();
        return R.newSuccessResult(maps,total);
    }

    @ApiOperation(value = "预约已完成")
    @PostMapping("/selectBysubscribe2")
    public R selectBysubscribe2(String visitorname,Integer pageNum,Integer pageSize){
        Page page = PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> maps = visitorSubscribeService.selectBysubscribe2(visitorname);
        Long total = page.getTotal();
        return R.newSuccessResult(maps,total);
    }

    @ApiOperation(value = "访客预约待审批数量")
    @GetMapping("/selectSubscribeNum")
    public Result selectSubscribeNum(){
        return Result.newSuccessResult(visitorSubscribeService.selectSubscribeNum());
    }

    @ApiOperation(value = "访客预约审批中数量")
    @GetMapping("/selectSubscribe1Num")
    public Result selectSubscribe1Num(){
        return Result.newSuccessResult(visitorSubscribeService.selectSubscribe1Num());
    }

    @ApiOperation(value = "访客预约已审批数量")
    @GetMapping("/selectSubscribe2Num")
    public Result selectSubscribe2Num(){
        return Result.newSuccessResult(visitorSubscribeService.selectSubscribe2Num());
    }
    @GetMapping("/selectSubscribeDetail")
    @ApiOperation("当日预约详情")
    public Result selectSubscribeDetail(){
        return Result.newSuccessResult(visitorSubscribeService.selectSubDetail());
    }

}
